import { PetArenaRewardInfo } from "./info/PetArenaRewardInfo";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class PetArenaRewardConfig
    
    export  class PetArenaRewardConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (PetArenaRewardConfig._instance != null) 
            {
                throw new Error(" PetArenaRewardConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new PetArenaRewardInfo();
                loc1.rank = loc2.rank;
                loc1.rankMax = loc2.rankMax;
                loc1.rewards = loc2.rewards;
                loc1.rewardType = loc2.rewardType;
                loc1.parse();
                this._map[loc1.rewardType + "_" + loc1.rank] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_arena_pet_reward.json");
            this.write(loc1);
            return;
        }

        public getPetArenaRewardInfo(arg1: int): PetArenaRewardInfo
        {
            var loc1=null;
            if (this._map[this._rankType + "_" + arg1]) 
            {
                return this._map[this._rankType + "_" + arg1];
            }
            var loc2=0;
            var loc3=this._map;
            for(loc1 of loc3) 
            {
                if (!(arg1 >= loc1.rank && arg1 <= loc1.rankMax && loc1.rewardType == 1)) 
                {
                    continue;
                }
                return loc1;
            }
            return null;
        }

        public getTop3Rewards(): Array<any>
        {
            var loc1=[];
            loc1.push(this.getPetArenaRewardInfo(2));
            loc1.push(this.getPetArenaRewardInfo(1));
            loc1.push(this.getPetArenaRewardInfo(3));
            return loc1;
        }

        public get4LaterRewards(): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            var loc4=this._map;
            for(loc2 of loc4) 
            {
                if (!(loc2.rank >= 4 && loc2.rewardType == this._rankType)) 
                {
                    continue;
                }
                loc1.push(loc2);
            }
            loc1.sortOn("rank", Array.NUMERIC);
            return loc1;
        }

        public static get instance(): PetArenaRewardConfig
        {
            if (PetArenaRewardConfig._instance == null) 
            {
                PetArenaRewardConfig._instance = new PetArenaRewardConfig();
            }
            return PetArenaRewardConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_rankType: int=1;

        /* internal */ static /* var */_instance: PetArenaRewardConfig;
    }
